/**
 * 控制器索引文件
 * 统一导出所有控制器
 */

// 导入控制器类
import { BaseController } from './BaseController'
import { UserController } from './UserController'
import { HabitsController } from './HabitsController'
import { FinanceController } from './FinanceController'
import { TimeController } from './TimeController'
import { TodosController } from './TodosController'
import { SettingsController } from './SettingsController'
import { UploadController } from './UploadController'
import { StatsController } from './StatsController'

// 导出控制器类
export {
  BaseController,
  UserController,
  HabitsController,
  FinanceController,
  TimeController,
  TodosController,
  SettingsController,
  UploadController,
  StatsController
}

// 控制器实例
const userController = new UserController()
const habitsController = new HabitsController()
const financeController = new FinanceController()
const timeController = new TimeController()
const todosController = new TodosController()
const settingsController = new SettingsController()
const uploadController = new UploadController()
const statsController = new StatsController()

export {
  userController,
  habitsController,
  financeController,
  timeController,
  todosController,
  settingsController,
  uploadController,
  statsController
}

// 控制器映射，方便动态调用
export const controllers = {
  user: userController,
  habits: habitsController,
  finance: financeController,
  time: timeController,
  todos: todosController,
  settings: settingsController,
  upload: uploadController,
  stats: statsController
}

// 控制器类型定义
export type ControllerType = keyof typeof controllers

// 获取控制器实例
export function getController(type: ControllerType) {
  return controllers[type]
}

// 批量初始化所有控制器
export async function initializeControllers() {
  try {
    // 这里可以添加控制器初始化逻辑
    console.log('Controllers initialized successfully')
    return true
  } catch (error) {
    console.error('Failed to initialize controllers:', error)
    return false
  }
}